package define;


public enum ReferenceExtraType 
{
	E_ARRAY_RET('[', ']'),
	E_LIST_RET('<', '>'),
	E_MAP_RET('<', '>'),
	E_POINT_RET(Config.CODE_NO_CHAR, '*'),
	E_REFERENCE_RET(Config.CODE_NO_CHAR, '&'),
	;
	
	private char m_start;
	private char m_end;
	
	private static String[] m_java = {"", "ArrayList", "HashMap", null, null};
	private static String[] m_flex = {"Array", "Vector.", "Dictionary", null, null};
	private static String[] m_cpp = {"", "std::vector", "std::map", "", ""};
	
	private ReferenceExtraType(char start, char end)
	{
		m_start = start;
		m_end = end;
	}
	
	public String getCodeValue(CodeOut co)
	{
		switch(co)
		{
		case E_JAVA_CO:
			return m_java[this.ordinal()];
		case E_FLEX_CO:
			return m_flex[this.ordinal()];
		case E_CPP_CO:
			return m_cpp[this.ordinal()];
		default:
			return null;
		}
	}
	
	public char getStart()
	{
		return m_start;
	}
	
	public char getEnd()
	{
		return m_end;
	}
	
	public boolean isOnlyEnd()
	{
		return m_start == Config.CODE_NO_CHAR;
	}
	
	public static ReferenceExtraType checkExtraTypeByStart(char ch)
	{
		for(ReferenceExtraType ret: ReferenceExtraType.values())
		{
			if(ret.getStart() == ch)
			{
				return ret;
			}
		}
		return null;
	}
	
	public static ReferenceExtraType checkExtraTypeByEnd(char ch)
	{
		for(ReferenceExtraType ret: ReferenceExtraType.values())
		{
			if(ret.getEnd() == ch)
			{
				return ret;
			}
		}
		return null;
	}
	
	public static boolean isUseExternString(ReferenceExtraType ret)
	{
		return ret == E_POINT_RET;
	}
	
	public static boolean isSplitType(ReferenceExtraType ret)
	{
		return ret == E_MAP_RET;
	}
	
	public String getErrorText()
	{
		if(isOnlyEnd())
		{
			return "" + m_end;
		}
		else
		{
			return m_start + " " + m_end;
		}
	}
}
